package com.ss.android.article.browser.dialog;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;

import com.a.a.s;
import com.ss.android.article.browser.R;
import com.ss.android.article.browser.WebViewClientDelegate;
import com.ss.android.article.browser.c.SpecialPageHelper;
import com.ss.android.article.browser.database.BrowserHistory;
import com.ss.android.article.browser.database.a.e;
import com.ss.android.article.browser.database.b.HistoryManager;
import com.ss.android.article.browser.database.b.h;
import com.ss.android.article.browser.database.bookmark.m;
import com.ss.android.article.browser.preference.PreferenceManager;
import com.ss.android.common.dialog.AlertDialog;

public class LightningDialogBuilder {
    public enum NewTab {
        FOREGROUND,
        BACKGROUND,
        INCOGNITO
    }
    m a;
    e b;
    h c;
    private static LightningDialogBuilder d;

    private LightningDialogBuilder() {
        this.a = com.ss.android.article.browser.database.bookmark.a.a();
        this.b = com.ss.android.article.browser.database.a.b.a();
        this.c = HistoryManager.getInstance();
        PreferenceManager.getInstance();
        com.ss.android.article.browser.download.a.a.a();
    }

    public static LightningDialogBuilder a() {
        if (LightningDialogBuilder.d == null) {
            Class v1 = LightningDialogBuilder.class;
            synchronized (v1) {
                if (LightningDialogBuilder.d == null) {
                    LightningDialogBuilder.d = new LightningDialogBuilder();
                }
            }
        }

        return LightningDialogBuilder.d;
    }

    static void a(LightningDialogBuilder arg10, Activity arg11, BrowserHistory arg12) {
        AlertDialog.Builder v4 = new AlertDialog.Builder(((Context) arg11));
        v4.setTitle(com.ss.android.article.browser.R.string.zv);
        View v5 = View.inflate(((Context) arg11), R.layout.cg, null);
        View v6 = v5.findViewById(com.ss.android.article.browser.R.id.r2);
        ((EditText) v6).setText(arg12.title);
        View v7 = v5.findViewById(com.ss.android.article.browser.R.id.r3);
        ((EditText) v7).setText(arg12.url);
        View v3 = v5.findViewById(com.ss.android.article.browser.R.id.r4);
        ((AutoCompleteTextView) v3).setHint(com.ss.android.article.browser.R.string.lc);
        ((AutoCompleteTextView) v3).setText(arg12.c);
        s v9 = arg10.a.d();
        ((com.a.a.e) v9).b = android.support.design.a.c();
        ((com.a.a.e) v9).c = android.support.design.a.b();
        v9.a(new com.ss.android.article.browser.dialog.f(arg10, arg11, ((AutoCompleteTextView) v3), v4, v5, ((EditText) v6), ((EditText) v7), arg12));
    }

    public final void a(@NonNull Activity arg5) {
        android.support.design.a.a(arg5, R.string.bq, new d[]{new aj(this)});
    }

    public final void a(@NonNull Activity arg7, @NonNull WebViewClientDelegate arg8, @NonNull String arg9) {
        if (SpecialPageHelper.isBookmarksUrl(arg9)) {
            String v0 = Uri.parse(arg9).getLastPathSegment();
            v0 = v0.substring(0, v0.length() - 15);
            BrowserHistory v1 = new BrowserHistory();
            v1.h = true;
            v1.setTitle(v0);
            v1.icon = R.drawable.ff;
            v1.setUrl("folder://" + v0);
            android.support.design.a.a(arg7, R.string.bu, new d[]{new i(this, arg7, v1), new j(this, v1)});
        } else {
            s v0_1 = this.a.a(arg9);
            ((com.a.a.e) v0_1).b = android.support.design.a.c();
            ((com.a.a.e) v0_1).c = android.support.design.a.b();
            v0_1.a(new com.ss.android.article.browser.dialog.e(this, arg7, arg8));
        }
    }

    public final void a(@NonNull Activity arg5, String arg6) {
        android.support.design.a.a(arg5, R.string.bz, new d[]{new com.ss.android.article.browser.dialog.m(), new n(), new o(), new p(arg5, arg6), new q(arg5, arg6), new r(this, arg6)});
    }

    public static void b(@NonNull Activity arg4, String arg5) {
        android.support.design.a.a(arg4, arg5.replace("http://", ""), new d[]{new u(arg4, arg5), new v(arg4, arg5), new w(arg5)});
    }

    static void b(LightningDialogBuilder arg5, Activity arg6, BrowserHistory arg7) {
        String v1 = arg7.title;
        c v2 = new c(arg5, arg7);
        View v3 = LayoutInflater.from(((Context) arg6)).inflate(com.ss.android.article.browser.R.layout.ch, null);
        View v0 = v3.findViewById(com.ss.android.article.browser.R.id.r5);
        ((EditText) v0).setHint(com.ss.android.article.browser.R.string.lw);
        if (v1 != null) {
            ((EditText) v0).setText(((CharSequence) v1));
        }

        android.support.design.a.resizeDialog(((Context) arg6), new AlertDialog.Builder(((Context) arg6)).setTitle(com.ss.android.article.browser.R.string.a05).setCustomTitle(v3).setPositiveButton(com.ss.android.article.browser.R.string.c_, new com.ss.android.article.browser.dialog.b(v2, ((EditText) v0))).show());
    }

    public static void c(@NonNull Activity arg3, String arg4) {
        android.support.design.a.a(arg3, arg4, new d[]{new x(), new y(), new z(), new aa(arg3, arg4), new ab(arg3, arg4)});
    }
}

